<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>物业收费管理</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/dist.css">
</head>
<body>
<h1>物业收费管理</h1>
<div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">日期范围</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="dateFrom">
        </div>
    </div>
    <div class="layui-inline">
        <button class="layui-btn layui-btn-primary">看本月</button>
    </div>
    <div class="layui-inline" id="control">
        <div class="layui-btn-group">
            <button class="layui-btn" onclick="addRow(table)">增加</button>
            <button class="layui-btn" onclick="changeRows(chosedRows)">编辑</button>
            <button class="layui-btn layui-btn-danger" onclick="delRows(chosedRows)">删除</button>
        </div>
        <button class="layui-btn layui-btn-normal" onclick="confirm(submit_args)">确认更改</button>
    </div>
</div>
<table class="layui-table">
    <thead>
    <tr id="table_head">
        <td class="layui-form" id="choseAll">
            <input type="checkbox" lay-skin="primary">
        </td>
        <td>收费编号</td>
        <td>住户姓名</td>
        <td>物业地址</td>
        <td>年份</td>
        <td>月份</td>
        <td>收费项目</td>
        <td>收费方式</td>
        <td>应收金额</td>
        <td>已交金额</td>
        <td>欠费金额</td>
        <td>缴费日期</td>
        <td>办理人</td>
    </tr>
    </thead>
    <tbody id="show">
    </tbody>
</table>
<button onclick="getNext(-5,table)">上一页</button>
<button onclick="getNext(5,table)">下一页</button>
</body>
<script src="/layui/layui.js"></script>
<script src="/js/init.js"></script>
<script src="/js/fetch.js"></script>
<script src="/js/checkTable.js"></script>
<script src="/js/admin/submit.js"></script>
<script src="/js/admin/addRow.js"></script>
<script>

    let identity = 'user';
    document.getElementById('control').style.display = 'none';
    document.getElementById('choseAll').style.display = 'none';

    checkLogin('物业收费管理').then(e => {
        order = checkTable(table, head);
        if (e.admin) {
            identity = 'admin';
            document.getElementById('control').style.display = 'block';
            document.getElementById('choseAll').style.display = 'block';
            init(identity);
        }else if (e.see) {
            order.shift();
            init(identity);
        }else document.write('<h1>对不起，你没有相关权限！</h1>');
        getNext(0, table);
    });

    let page_no = 0;
    let table = document.getElementById('show');
    let head = document.getElementById('table_head');
    let order;
    let submit_args = [];
    let admin_table = [];

    function init() {

        if (identity !== 'admin') {

        } else {
            admin_table.push({
                    type: 'checkbox',
                    content: 'chose',
                    isNode: true
                }, {
                    tip: '请填写收费编号',
                    content: order[1],
                    beSubmit: 'ChargeId',
                    isPrimary: true//删除的唯一标识字段
                }, {
                    tip: '请填写住户姓名',
                    content: order[2],
                    required: true,
                    beSubmit: 'ownerName'

                }, {
                    tip: '请填写物业地址',
                    content: order[3],
                    required: true,
                    beSubmit: 'serverAddress'

                }, {
                    content: function (spans) {
                        return spans[0] + '-' + spans[1]
                    },

                    type: 'month',
                    col_span: 2,
                    span_group: [4, 5],
                    required: true,
                    beSubmit: 'ChargeDate'

                }, {
                    tip: '填写收费项目',
                    content: order[6],
                    beSubmit: 'ChargeP'

                }, {
                    tip: '请填写收费方式',
                    content: order[7],
                    beSubmit: 'ChargeWay'

                }, {
                    tip: '请填写应收金额',
                    content: order[8],
                    beSubmit: 'ChargeStandard'

                }, {
                    tip: '填写已交金额',

                    content: order[9],
                    beSubmit: 'PayReal'

                }, {
                    tip: '请填写欠费金额',
                    content: order[10],
                    beSubmit: 'PayBalance'

                }, {
                    tip: '请填写缴费日期',
                    content: order[11],
                    beSubmit: 'ChargeTime',
                    type: 'date'

                },


                {
                    tip: '请填写办理人',
                    content: order[12],
                    beSubmit: 'ChargeName'
                });

        }
    }



    let chosedRows = [];
</script>
</html>